package com.marver.common.enumeration;

/**
 * @description: ip黑白名单枚举
 * @Author: Marver
 * @date: 2018-04-23 16:22
 **/
public enum IpTypEnum {
    WHITE_IP(0,"白名单","WHITEIP:"),
    BLACK_IP(1,"黑名单","BLACKIP:");

    private Integer id;
    private String text;
    private String key;

    IpTypEnum(Integer id,String text,String key){
        this.id = id;
        this.text = text;
        this.key = key;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    // 通过id得到key方法
    public static String getByKey(Integer id) {
        for (IpTypEnum c : IpTypEnum.values()) {
            if (c.getId().equals(id)) {
                return c.key;
            }
        }
        throw new IllegalArgumentException("No element matches " + id);
    }
}
